﻿using System;
using CompositeKey.Model;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace CompositeKey
{
    public class Program
    {
        public static void Main()
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    var user = new User(session) {
                        Name = "Jon Skeet"
                    };

                    var group = new Group(session) {
                        Name = "C# Experts"
                    };

                    // Passing session and primary key values
                    var membership = new Membership(session, user, group);

                    t.Complete();
                }
            }
        }
    }
}
